from typing import Any

class MockPWM:
    """
    Mock PWM class
    Used for testing PWM functionality without hardware
    """
    def __init__(self, pin_id: int) -> None:
        self.pin_id = pin_id
        self.frequency = 0
        self.duty_cycle = 0
        self.is_active = False

    def freq(self, freq: int) -> None:
        self.frequency = freq
        print(f"MockPWM {self.pin_id} frequency set to {freq} Hz")

    def duty(self, duty: int) -> None:
        self.duty_cycle = duty
        duty_percent = (duty / 1023) * 100
        print(f"MockPWM {self.pin_id} duty set to {duty} ({duty_percent:.1f}%)")

    def deinit(self) -> None:
        self.is_active = False
        print(f"MockPWM {self.pin_id} deactivated")

def set_pwm_mock(pin: Any, freq: int, duty: int) -> MockPWM:
    pwm = MockPWM(pin)
    pwm.freq(freq)
    pwm.duty(duty)
    pwm.is_active = True
    return pwm
